import 'package:hongsheng/pages/dialogs/SPClassPrivacyDialogDialog.dart';
import 'package:hongsheng/splash_screen.dart';
import 'package:hongsheng/utils/SPClassNavigatorUtils.dart';
import 'package:hongsheng/utils/SPClassUtil.dart';
import 'package:hongsheng/utils/LocalStorage.dart';
import 'package:hongsheng/utils/common.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';


class InitPage extends StatefulWidget {
  const InitPage({Key ?key}) : super(key: key);

  @override
  _InitPageState createState() => _InitPageState();
}

class _InitPageState extends State<InitPage> {
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(BoxConstraints(
        maxWidth: MediaQuery.of(context).size.width,
        maxHeight: MediaQuery.of(context).size.height),
        context: context, designSize: const Size(360, 640));
    return Scaffold(
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        color: Colors.white,
      ),
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    if(LocalStorage.get(Commons.IS_AGREE_PRIVICY)!=null){
      Future.delayed(const Duration(seconds: 1)).then((value) async{
        SPClassNavigatorUtils.pushAndRemoveAll(context, SplashScreen());
      });
    }else{
      Future.delayed(const Duration(seconds: 1)).then((value) {
        showDialog(context: context,builder: (context){
          return SPClassPrivacyDialogDialog( ()async{
            SPClassNavigatorUtils.pushAndRemoveAll(context, SplashScreen());
            //SPClassUtil.spFunRequestPermission();
          });
        });
      });
    }
  }
}
